package Month07.day24.stu.test4;

import java.util.ArrayList;

public class test {

    public static void main(String[] args) {
        Student student = new Student("袁康",80,23);
        Student student1 = new Student("黄海",80,25);
        Student student2 = new Student("杨政",81,21);
        Student student3 = new Student("康亮",80,23);
        Student student4 = new Student("邹兆宇",80,22);
        ArrayList<Student> list = new ArrayList <>();
        list.add(student);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        Student s=getMaxScore(list);
        System.out.println(s);
        getSvg(list);
        getNo(list);
    }
    private static Student getMaxScore(ArrayList<Student> collection){
        Student student1 = new Student();
        int Max= collection.get(0).getScore();
        for (int i = 0; i < collection.size(); i++) {
            Student student=collection.get(i);
            if (Max<student.getScore()){
                Max= student.getScore();
                student1=student;
            }
        }
        return student1;
//        for (int i = 0; i < collection.size(); i++) {
//            Student student=collection.get(i);
//            if (student.getScore()==Max){
//                System.out.println(student);
//            }
//        }
    }
    private static void getSvg(ArrayList<Student> list){
        int sum=0;
        for (int i = 0; i < list.size(); i++) {
            Student student=list.get(i);
             sum+=student.getScore();
        }
        double n=sum/(list.size());
        System.out.println(n);
    }
    private static void getNo(ArrayList<Student> list){
        ArrayList<Student> list1 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Student student=list.get(i);
            if (student.getScore()<90){
                list1.add(student);
            }
        }
        System.out.println("一共有"+list1.size()+"个不及格");
        System.out.print(list1);
    }
}
